/**
 * 定义通用业务数据
 */
export default {
  namespaced: "common",
  state: {
    token: "",  //token
    userInfo: {}, //用户信息
    userRole: [], //角色信息
    weather:null  //天气情况
  },
  mutations: {
    SAVE_TOKEN(_state, token) {
      //存储token
      _state.token = token;
    },
    SAVE_USERINFO(_state, userInfo) {
      //存储用户信息
      _state.userInfo = userInfo;
    },
    SAVE_USERROLE(_state, userRole) {
      //存储角色信息
      _state.userRole = userRole;
    },
    //存储天气情况
    SAVE_WEATHER(_state,weather){
      _state.weather = weather;
    },
    //清除缓存
    REMOVE_STATE(_state){
      _state = {} 
    }
  },
  getters: {
    token: (_state) => _state.token,
    userRole: (_state) => _state.userRole,
    userInfo: (_state) => _state.userInfo,
    weather: (_state) => _state.weather,
    
  },
};
